package com.devhelper.examples.gef.part;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;

import com.devhelper.examples.gef.model.Department;
import com.devhelper.examples.gef.model.Employee;
import com.devhelper.examples.gef.model.Enterprise;

public class ExEditPartFactory implements EditPartFactory {

    @Override
    public EditPart createEditPart(EditPart context, Object model) {
        AbstractGraphicalEditPart part = null;

        if (model instanceof Enterprise) {
            part = new EnterpriseEditPart();
        } else if (model instanceof Department) {
            part = new DepartmentEditPart();
        } else if (model instanceof Employee) {
            part = new EmployeeEditPart();
        }

        part.setModel(model);

        return part;
    }

}
